/*
day221
2020.4.5
*/

#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    vector<vector<int>> intervalIntersection(vector<vector<int>>& A, vector<vector<int>>& B) {
		vector<vector<int>> res;
		vector<int> tem={0,-1};
		for(int i=0,j=0;i<A.size()&&j<B.size();)
		{
			const vector<int> &vec_A=A[i];
			const vector<int> &vec_B=B[j];
			
			tem[0]=max(vec_A[0],vec_B[0]);
			tem[1]=min(vec_A[1],vec_B[1]);
			
			if(vec_A[1]>vec_B[1]) ++j;
			else ++i;
			
			if(tem[1]>=tem[0])
			{
				res.push_back(tem);
			}
		} 
		return res;	
    }
};

int main()
{
	return 0;
}
